<?php

use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;

class CreateUserChatTable extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('user_chat', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->integer('user_id')->default(0)->comment('用户ID');
            $table->integer('chat_user_id')->default(0)->comment('聊友ID');
            $table->tinyInteger('flag')->default(1)->comment('1：有效，0：无效');
            $table->tinyInteger('from')->default(1)->comment('入口：1-动态，2-打招呼');
            $table->timestamps();
            $table->index(['user_id', 'chat_user_id'], 'user_chat');
            $table->index(['chat_user_id', 'user_id'], 'chat_user');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('user_chat');
    }
}
